package selef.xiafan.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import selef.xiafan.entity.order.Order;
import selef.xiafan.service.ICommentService;
import selef.xiafan.service.ICustomerService;
import selef.xiafan.service.IOrderItemService;
import selef.xiafan.service.IOrderService;
import selef.xiafan.util.result.Result;
import selef.xiafan.util.result.ResultFactory;

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.util.*;

/**
 * @author xiafan
 * @version 1.0
 * @date 2021/11/11 17:10
 */
@RestController
@RequestMapping("/api/home")
public class HomeController {
    @Autowired
    ICustomerService iCustomerService;
    @Autowired
    IOrderService iOrderService;
    @Autowired
    ICommentService iCommentService;

    @GetMapping("/getItemData")
    public Result getItemData() {
        int customerSize = iCustomerService.getAll().size();
        int dayOrder = iOrderService.getDayOrder().size();
        int allOrder = iOrderService.getAll().size();
        int commentSize = iCommentService.getAll().size();
        Map<String, Integer> map = new HashMap<String, Integer>();
        map.put("customerSize", customerSize);
        map.put("dayOrder", dayOrder);
        map.put("allOrder", allOrder);
        map.put("commentSize", commentSize);
        return ResultFactory.buildResult(200, "成功", map);
    }

    /**
     * 后台数据图展示
     * */
//    @GetMapping("/getVisitiesData")
//    public Result getVisitiesData(){
//        List<Order> ordersWeek = iOrderService.queryWeekData();
//        Map<String, Object> hashMap = new HashMap<>();
//        hashMap.put("ordersWeek",ordersWeek);
//        return ResultFactory.buildResult(200,"",hashMap);
//    }
}

